package com.exrobot.module.rbt.mq.producer.deliveryFood;

import com.alibaba.fastjson.JSON;
import com.exrobot.module.rbt.mq.message.deliveryFood.DeliveryFoodMessage;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * 取餐完成相关消息的 Producer
 *
 * @author exbot
 * @since 2025/4/19 13:33
 */
@Slf4j
@Component
public class DeliveryFoodProducer {

    @Resource
    private ApplicationContext applicationContext;

    /**
     * 发送 {@link DeliveryFoodMessage} 消息
     *
     * @param deliveryFoodMessage 订单对象
     */
    public void sendDeliveryFoodMessage(DeliveryFoodMessage deliveryFoodMessage) {
        applicationContext.publishEvent(deliveryFoodMessage);
        log.info("[RedisMQ-取餐]发送消息内容：{}", JSON.toJSONString(deliveryFoodMessage));
    }

}
